#include "iostream"
#include <cstdlib>
#include <cstdio>
using namespace std;

//1 new delete 操作符号 c++的关键字
//malloc free函数

//2 new 在堆上分配内存  delete 
//分配基础类型 、分配数组类型、分配对象

//3


int main()
{
    {
        //new基础类型
        int *p1 = (int *)malloc(sizeof(int)); 
        *p1 = 1;
        printf("*p1:%d \n", *p1);
        free(p1);
    }

    {
        int *p2 = new int; //相当于上面的
        *p2 = 2;
        printf("*p2:%d \n", *p2);
	    delete p2;
    }

    {
        //分配内存的同时，初始化
        int *p3 = new int(3);
        printf("*p3:%d \n", *p3);
        delete p3;
    }



	return 0;
}
